/**
 * 
 */
package com.suyx.job.utils.mh;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.suyx.job.utils.ScreenCapture;

import lombok.extern.slf4j.Slf4j;

/**
 * @author syx
 *
 */
@Slf4j
@Component
public class JycScene {

	@Autowired
	private WaTuUtils waTuUtils;
	
	public final static Map<String,String> options_x = new HashMap<>();  
	public final static Map<String,String> options_y = new HashMap<>();
	static {  
		options_x.put("0", "630 297");  
		options_x.put("1", "328 205");  
		options_x.put("2", "428 205");
		options_x.put("3", "528 205"); 
		options_x.put("4", "328 305");
		options_x.put("5", "428 305");
		options_x.put("6", "528 305");
		options_x.put("7", "328 405");
		options_x.put("8", "428 405");
		options_x.put("9", "528 405");
		
		options_y.put("0", "763 297");  
		options_y.put("1", "463 197");  
		options_y.put("2", "563 197");
		options_y.put("3", "663 197"); 
		options_y.put("4", "463 297");
		options_y.put("5", "563 297");
		options_y.put("6", "663 297");
		options_y.put("7", "463 397");
		options_y.put("8", "563 397");
		options_y.put("9", "663 397");
	} 
	
	public  void jyc(String device ,String zuobiao,String baoguo) throws Exception{
		//打开包裹
		ScreenCapture.mouseClick(device, "1308 675");
		ScreenCapture.mouseClick(device, "906 233");// 打开傲来7
		ScreenCapture.mouseClick(device, "522 422");// 使用
		ScreenCapture.mouseClick(device, "887 547");//7到傲来到东海湾驿站坐标
		ScreenCapture.mouseClick(device, "1156 52");// 关闭包裹
		ScreenCapture.mouseClick(device, "808 345");// 点击驿站传输
        ScreenCapture.mouseClick(device, "1233 344");// 传送确认到达东海湾  
        
        Thread.sleep(2 * 1000L);
        ScreenCapture.mouseClick(device, "117 68");//打开地图
        ScreenCapture.mouseClick(device, "577 572");
        Thread.sleep(14 * 1000L);
        ScreenCapture.mouseClick(device, "1053 84"); //关闭地图
        ScreenCapture.mouseClick(device, "40 630");  
	}
	
	public  void jycSceneSame(String device,String zuobiao,String baoguo) throws Exception{
		Thread.sleep(2 * 1000L);
		ScreenCapture.mouseClick(device, "117 68");//打开地图
        ScreenCapture.mouseClick(device, "352 87");// 选x坐标
        String x = zuobiao.split(" ")[0];
        String y = zuobiao.split(" ")[1];
        input_x(device,x);
        ScreenCapture.mouseClick(device, "628 405");
        ScreenCapture.mouseClick(device, "486 87"); // 选y坐标
        input_y(device, y);
        ScreenCapture.mouseClick(device, "763 397");
        ScreenCapture.mouseClick(device, "620 88");  // 前往
        ScreenCapture.mouseClick(device, "1205 55"); //关闭地图
        
        //开始挖图
        waTuUtils.startWatu(device, zuobiao, baoguo);
	}
	
	private void input_x(String device,String x){
		for(int i =0;i<x.length();i++){
			char c = x.charAt(i);
			String x_zb = options_x.get(String.valueOf(c));
			ScreenCapture.mouseClick(device, x_zb);
		}
	}
	
	private void input_y(String device,String y){
		for(int i =0;i<y.length();i++){
			char c = y.charAt(i);
			String y_zb = options_y.get(String.valueOf(c));
			ScreenCapture.mouseClick(device, y_zb);
		}
	}
	
}
